package com.lj.infoisland.common.enums;

import lombok.Getter;
import lombok.Setter;

@Getter
public enum UserActionTypeEnum {
    VIEW("浏览", "view"),
    CLICK("点击", "click"),
    COMMENT("评论", "comment"),
    LIKE("点赞", "like"),
    FAVORITE("收藏", "favorite"),
    LOGIN("登录", "login"),
    LOGOUT("登出", "logout"),
    REGISTER("注册", "register"),;

    private final String description;
    private final String name;

    UserActionTypeEnum(String description, String name) {
        this.description = description;
        this.name = this.name();
    }

    public String getDescription() {
        return description;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据name获取description
     *
     * @param name name
     * @return description
     */
    public static String name2Description(String name) {
        for (UserActionTypeEnum userActionTypeEnum : UserActionTypeEnum.values()) {
            if (userActionTypeEnum.getName().equals(name)) {
                return userActionTypeEnum.getDescription();
            }
        }
        return null;
    }
}